<?php

namespace App\Models\Admin;

use App\Models\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class UserModel extends Model
{
    const User_Admin = 1;

    public function __construct(array $attributes = [])
    {
        $this->table = config('admin-api.database.user_table');
        parent::__construct($attributes);
    }

    public function roles(): BelongsToMany
    {
        $pivotTable = config('admin-api.database.user_role_table');
        return $this->belongsToMany(RoleModel::class, $pivotTable, 'user_id', 'role_id')->withTimestamps();
    }
}
